package cn.b.sky.mes.cm.model;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import cn.b.sky.common.model.ImeCommon;
import cn.b.sky.common.model.TreeInterface;
import cn.b.sky.user.SecurityContextUtil;
import org.apache.commons.lang3.StringUtils;

/**
 * 
 * <strong>Title : WorkCenter.java<br></strong>
 * <strong>Package : cn.b.sky.mes.cm.model<br></strong>
 * <strong>Description : </strong>工作中心实体类<br> 
 * <strong>Create on : 2015-9-24 上午11:22:42<br></strong>
 * <p>
 * @author lidapeng<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人 | 修改日期 | 修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
public class WorkCenter extends ImeCommon implements TreeInterface, Serializable {
  /** 
  * @Fields serialVersionUID
  * @creator     :lidapeng
  */
  private static final long serialVersionUID = -4015298809030252751L;

  /**
   * 工作中心编号
   */
  private String workCenterCode;

  /**
   * 工作中心类型编号
   */
  private String workCenterTypeCode;

  /**
   * 工作中心类型描述
   */
  private String typeText;

  /**
   * 父级工作中心编号
   */
  private String parentWorkCenterCode;

  /**
   * 描述
   */
  private String workCenterText;

  /**
   * 新增工作日历
   */
  private String calendarCode;

  /**
   * 锁定标志
   * 默认不锁定
   */
  private Integer lockFlag = 0;

  private List<WorkCenter> childrens;

  /**
   * 作业单元集
   */
  private List<WorkUnit> workUnits = new LinkedList<WorkUnit>();

  /**
   * 线边仓库编号
   */
  private String warehouseCode;

  /**
   * 线边库位编号
   */
  private String storageLocationCode;

  public WorkCenter() {
    // Do nothing
  }

  public WorkCenter(String workCenterCode, String siteCode) {
    this.workCenterCode = workCenterCode;
    setSiteCode(siteCode);
  }

  public String getWorkCenterCode() {
    return StringUtils.upperCase(workCenterCode);
  }

  public void setWorkCenterCode(String workCenterCode) {
    this.workCenterCode = StringUtils.upperCase(workCenterCode);
  }

  public String getTypeText() {
    return typeText;
  }

  public void setTypeText(String typeText) {
    this.typeText = typeText;
  }

  public String getWorkCenterTypeCode() {
    return StringUtils.upperCase(workCenterTypeCode);
  }

  public void setWorkCenterTypeCode(String workCenterTypeCode) {
    this.workCenterTypeCode = StringUtils.upperCase(workCenterTypeCode);
  }

  public String getParentWorkCenterCode() {
    return parentWorkCenterCode;
  }

  public void setParentWorkCenterCode(String parentWorkCenterCode) {
    this.parentWorkCenterCode = parentWorkCenterCode;
  }

  public String getWorkCenterText() {
    return workCenterText;
  }

  public void setWorkCenterText(String workCenterText) {
    this.workCenterText = workCenterText;
  }

  public Integer getLockFlag() {
    return lockFlag;
  }

  public void setLockFlag(Integer lockFlag) {
    this.lockFlag = lockFlag;
  }

  public List<WorkCenter> getChildrens() {
    return childrens;
  }

  public void setChildrens(List<WorkCenter> childrens) {
    this.childrens = childrens;
  }

  @Override
  public String getSiteCode() {
    String siteCode = super.getSiteCode();
    if (org.apache.commons.lang3.StringUtils.isBlank(siteCode)) {
      siteCode = SecurityContextUtil.getSiteCode();
    }
    return siteCode;
  }

  @Override
  public void setTrees(List trees) {
    this.childrens = trees;
  }

  @Override
  public String getPid() {
    return this.parentWorkCenterCode;
  }

  @Override
  public String getNodeId() {
    return workCenterCode;
  }

  /**
   * 是否为叶子节点判断
   */
  public Boolean getIsLeaf() {
    if (this.childrens != null && this.childrens.size() > 0) {
      return false;
    }

    return true;
  }

  public String getCalendarCode() {
    return calendarCode;
  }

  public void setCalendarCode(String calendarCode) {
    this.calendarCode = calendarCode;
  }

  public List<WorkUnit> getWorkUnits() {
    return workUnits;
  }

  public void setWorkUnits(List<WorkUnit> workUnits) {
    this.workUnits = workUnits;
  }

  public String getWarehouseCode() {
    return warehouseCode;
  }

  public void setWarehouseCode(String warehouseCode) {
    this.warehouseCode = warehouseCode;
  }

  public String getStorageLocationCode() {
    return storageLocationCode;
  }

  public void setStorageLocationCode(String storageLocationCode) {
    this.storageLocationCode = storageLocationCode;
  }

}
